import 'package:fluent_ui/fluent_ui.dart';

class Inputbox extends StatefulWidget {
  final String name;
  final Function(String) setFunction;
  final String inputvalue;

  const Inputbox(
      {super.key,
      required this.name,
      required this.setFunction,
      required this.inputvalue});

  @override
  State<StatefulWidget> createState() => _Inputbox();
}

class _Inputbox extends State<Inputbox> {
  TextEditingController controller = TextEditingController(text: inputvalue);
  static get inputvalue => null;

  @override
  Widget build(BuildContext context) {
    if (widget.inputvalue == "") {
      controller.text = "";
    }

    return Container(
        margin: const EdgeInsets.only(top: 20),
        child: InfoLabel(
          label: widget.name,
          labelStyle: const TextStyle(fontSize: 24, color: Colors.white),
          child: TextBox(
            autofocus: true,
            controller: controller,
            expands: false,
            style: const TextStyle(
                fontSize: 24, textBaseline: TextBaseline.alphabetic),
            onChanged: (value) {
              widget.setFunction(value);
            },
          ),
        ));
  }
}
